Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

174
Vistas
Get list of items from firestore in react native/[Unhandled promise rejection: FirebaseError: Expected type 'ba', but it was: a custom Oa object]

Hi there i need to get from my firestore db a list of items like this

items={{
    '2012-05-22': [{name: 'item 1 - any js object'}],
    '2012-05-23': [{name: 'item 2 - any js object', height: 80}],
    '2012-05-24': [],
    '2012-05-25': [{name: 'item 3 - any js object'}, {name: 'any js object'}]
  }}

This is my db structurefirestore db structure

So this is my code to do it but isnt working

const getUserEvents = () => {
  const FSquery = query( collection( FSdb, `usertasks/${user.uid}/events`) )
  const unsubscribe = onSnapshot( FSquery, ( querySnapshot ) => {
  // get all documents (using the date as id) from user's events collection
  let eventData = {}
  querySnapshot.forEach( (doc) => {
    console.log("testing id", doc.id)

  let arr = []
  // the id of the document is the date for the event
  eventData[ doc.id ] = arr
  console.log("testing array", arr)
  console.log("testing eventdata", eventData)

  })
  // now we get the collection of events for each day
  let eventsOfTheDay = []
  const eventKeys = Object.keys( eventData )
  eventKeys.map( async (eventDate) => {
  const events = await getDocs( FSdb, `users/${user.uid}/events/${eventDate}/items`)
  events.forEach( (doc) => {
  let event = doc.data()
  event.id = doc.id
  eventsOfTheDay.push( event )
  })
  
  eventData[ eventDate ] = eventsOfTheDay
  console.log("this are the eventsoftheday", eventsOfTheDay)

  })
  // now we can set it into a state that can be passed to components to be consumed by the calendar
  // eg setEvents( eventData )
  })
  }

I dont get any value from eventsoftheday not even the consloge string "this is eventsoftheday" Thanks i get this error [Unhandled promise rejection: FirebaseError: Expected type 'ba', but it was: a custom Oa object]

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

The getDocs function takes a Query as the only parameter but you are passing two.

const events = await getDocs(FSdb, `users/${user.uid}/events/${eventDate}/items`)

Try changing the above line to like this:

const events = await getDocs(
  collection(FSdb, `users/${user.uid}/events/${eventDate}/items`)
);
// ^^^
// add collection 
about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda